<?php

class User_AccountController extends Koncept_Rest_Resource_Controller
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $this->_redirect('/user');
    }

    public function getAction($id)
    {
        if($account = User_Model_User::findSingle($id)) {
            $form = new User_Form_Account;
            $form->setAccountId($account->username);
            $form->setUsername($account->username);
            $form->setEmail($account->email);
            $form->setPassword($account->password);
            $this->view->form = $form;
            $this->view->account = $account;
            $this->view->pageTitle = "User account $id";
            $this->view->bodyTitle = "User account $id";
        } else {
            $this->getResponse()->setHttpResponseCode(404);
            $this->view->pageTitle = "User $id not found";
            $this->view->bodyTitle = "User $id not found";
        }
    }

    public function postAction()
    {
        $user = $this->getParam('user');
        if(is_array($user)) {
            $usermodel = new User_Model_User;
            $usermodel->fromArray($user);
            $result = $usermodel->save();
            var_dump($result);
        }
    }

    public function putAction()
    {
        // action body
    }

    public function deleteAction()
    {
        // action body
    }


}









